/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment1;

import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;

/**
 *
 * @author Karin West
 * Student No: 201099764 [part-time]
 */
public class TestAssignment1 {
    
    @Test
    public void testFloatMethod()
    {
	Assignment1 val1 = new Assignment1();
				
	val1.setnumOne(123456789.345f);
				
	float expected = 123456789.345f;
	float actual = val1.getnumOne();
        

        assertEquals(expected, actual,0.5);
    }
    
   @Test
    public void testIntegerMethod()
    {
        Assignment1 num1 = new Assignment1();
				
        num1.setnumTwo(100);
				
	int expected = (100);
	int actual = num1.getnumTwo();

	assertEquals(expected, actual);
    }

  @Test
   public void testObjEquality()
   {
        Assignment1 a1 = new Assignment1(123456789.346f, 600, "Dan");
	Assignment1 a2 = new Assignment1(123456789.346f, 600, "Dan");
        
	assertEquals(a1.getnumOne(), a2.getnumOne(),05);
        assertEquals(a1.getnumTwo(), a2.getnumTwo());
        assertEquals(a1.getname(), a2.getname());
    }

    @Test
    public void testObjIdentity()
    {
	Assignment1 num1 = new Assignment1();
	Assignment1 num2 = new Assignment1();
				
	num1.setnumTwo(100);
				
	int expected = (100);
	int actual = num1.getnumTwo();

	assertSame(expected, actual);
				
	num1.setnumTwo(100);
				
	int exp = (100);
	int act = num1.getnumTwo();

	assertSame("Objects reference point to the same object", exp, act);

	num2.setnumTwo(500);

	int expect = (500);
	int actl = num2.getnumTwo();

	assertNotSame("Objects does not point to the same object", expect, actl);
    }

    @Test
    public void testAssertTrue()
    {
        
	Assignment1 num1 = new Assignment1();
				
	num1.setnumTwo(100);
        				
	int expected = (100);
	int actual = num1.getnumTwo();

	assertTrue(expected == actual);
    }
	
    @Test
    public void testAssertFalse()
    {
	Assignment1 num1 = new Assignment1();
				
	num1.setnumTwo(150);
				
	int expected = (150);
	int actual = num1.getnumTwo();

	assertFalse(expected < actual);
    }
    
    @Test
    public void fail()
    {
        Assignment1 name1 = new Assignment1();
				
	name1.setname("Sam");
				
	String expected = ("Sam");
	String actual = name1.getname();
        
        assertEquals("Failing on purpose", expected, actual);
       	
    }

    @Test(timeout=1)
    public void testConsumingTime()
    {
        Assignment1 num1 = new Assignment1();
				
        num1.setnumTwo(100);
				
        int expected = (100);
        int actual = num1.getnumTwo();

        assertEquals(expected, actual);
    }

    @Ignore("this regular expression is not working yet")
    @Test
    public void testIgnore()
    {
	Assignment1 name1 = new Assignment1();
				
	name1.setname("Mike");
				
	String expected = ("Mike");
	String actual = name1.getname();

	assertEquals(expected, actual);
	}
    
    @Test
    public void testmethodEqual()
    {
        Assignment1 name1 = new Assignment1();
				
	name1.setname("Sam");
				
	String expected = ("Sam");
	String actual = name1.getname();
        
        assertEquals(expected, actual);
       	
    }
}
